package metamodel;

import java.util.LinkedList;
import java.util.List;

public class Method implements Accessorizable {

//	private Map<String, Attribute> parameters;
	
	private String name;
	
	private String returnType;
	
	private String accessor;

	private LinkedList<Attribute> orderedParameters;

	public Method(String name, String returnType, String accessor) {
		this.name = name;
		this.returnType = returnType;
		this.accessor = accessor;
//		this.parameters = new HashMap<String, Attribute>();
		this.orderedParameters = new LinkedList<Attribute>();
	}
	
	public String getName() {
		return this.name;
	}
	
	public String getReturnType() {
		return this.returnType;
	}
	
	public String getType() {
		return this.getReturnType();
	}

	public void setAccessor(String accessor) {
		this.accessor = accessor;
	}
	
	public String getAccessor() {
		return accessor;
	}

	public void addParameter(Attribute attribute) {
//		this.parameters.put(attribute.getName(), attribute);
		this.orderedParameters.add(attribute);
	}
	
	public List<Attribute> getParameters() {
		return this.orderedParameters;
	}
	
	public String toString(){
		String result = this.getName()+"(";
		for (Attribute param : this.getParameters()){
			result += param.getName()+":"+param.getType()+",";
		}
		result = this.getParameters().size() > 0 ? result.substring(0, result.length()-1) : result;
		result += "):"+this.getReturnType();
		return result;
	}
	
}
